<?php
	include(CMS_DIR . "/model/" . $model . ".class.php");
	/**
	*模型字段管理控制模块
	**/
	class Field {
		// 构造函数
		public function __constract(){
		}

		// 模型字段列表
		public function fieldlist($data){
			$field = new FieldClass();
			$fieldList = $field->getList($data);
			returnAjaxJson(200, "操作成功！", $fieldList);
		}

		// 添加模型字段
		public function add($data){
			// 验证类型值范围
			$fieldArr = array("id", "catid", "title", "description", "creator", "create_time", "recommend", "pic");
			if(valifyRange($data->field, $fieldArr)){
				returnAjaxJson(400, "field参数不能为'id','catid','title','description','creator','create_time','recommend','pic'！", null);
			}

			$field = new FieldClass();
			$field->add($data);
			returnAjaxJson(200, "操作成功！", null);
		}

		// 编辑模型字段
		public function edit($data){
			// 验证id整数类型
			if(!is_int($data->id)){
				returnAjaxJson(400, "id格式错误！", null);
			}

			$field = new FieldClass();
			$field->edit($data);
			returnAjaxJson(200, "操作成功！", null);
		}

		// 删除模型字段
		public function del($data){
			// 验证id整数类型
			if(!is_int($data->id)){
				returnAjaxJson(400, "id格式错误！", null);
			}

			$field = new FieldClass();
			$field->del($data);
			returnAjaxJson(200, "操作成功！", null);
		}

	}
?>